﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;

using FCNS.Utility;
using FCNS.KeepMoney.Configuration;

namespace FCNS.KeepMoney.Util
{
    class ArgsUtil
    {
        public static void ArgsHelp()
        {
            StringBuilder msg = new StringBuilder();

            msg.Append("keepmoney [ -Compress ] [ -Decompress ] [ - LanToLng ] [ -LanToXml ] fileNameOrPathName");
            msg.Append("\r\n\r\n");
            msg.Append("-Compress 压缩指定文件夹.");
            msg.Append("\r\n");
            msg.Append("-Decompress 解压指定文件夹.");
            msg.Append("\r\n");
            msg.Append("-LanToLng 压缩语言文件,以 .lng 扩展名结尾.");
            msg.Append("\r\n");
            msg.Append("-LanToXml 解压语言文件,以 .xml 扩展名结尾.");
            msg.Append("\r\n");
            msg.Append("-Compress 压缩指定文件夹");

            System.Windows.Forms.MessageBox.Show(msg.ToString());
            //ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
            //info.CreateNoWindow = false;
            ////info.RedirectStandardOutput = true;
            //info.RedirectStandardInput = true;
            //info.UseShellExecute =false;
           
            //Process p = new Process();
            //p.StartInfo = info;
            //p.Start();
            //p.StandardInput.WriteLine("echo off");
            //p.StandardInput.WriteLine(":用法:");
            //p.StandardInput.WriteLine(": keepmoney [ -Compress ] [ -Decompress ] [ - LanToLng ] [ -LanToXml ] fileNameOrPathName");
            //p.StandardInput.WriteLine(":选项:");
            //p.StandardInput.WriteLine(": -Compress 压缩指定文件夹.");
            //p.StandardInput.WriteLine(": -Decompress 解压指定文件夹.");
            //p.StandardInput.WriteLine(": -LanToLng 压缩语言文件,以 .lng 扩展名结尾.");
            //p.StandardInput.WriteLine(": -LanToXml 解压语言文件,以 .xml 扩展名结尾.");
            //p.StandardInput.WriteLine(": -Compress 压缩指定文件夹");

            //p.WaitForExit();
        }

        public static void ComFile(string path)
        {
            GZip gzip = new GZip();
            gzip.Compress(path, "*.*", SearchOption.AllDirectories, AppDefines.appPath,
                "compress.gz", true);
        }

        public static void DecomFile(string path)
        {
            GZip gzip = new GZip();
            foreach (string file in Directory.GetFiles(path, "*.gz"))
            {
                gzip.Decompress(path, path, Path.GetFileName(file)).Errors.ToString();
                File.Delete(file);
            }
        }
    }
}
